﻿@model ProjectThuCung.Models.SanPham

@{
    ViewBag.Title = "EditSanPham";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}


<div style="margin:30px">
    <h2>Chỉnh sửa sản phẩm</h2>

    @using (Html.BeginForm()) {
        @Html.ValidationSummary(true)

        <fieldset>
            <legend>SanPham</legend>

            @Html.HiddenFor(model => model.SanPhamID)
            @Html.HiddenFor(model => model.ThongTinThemID)
            @Html.HiddenFor(model => model.LoaiSanPhamID)
       

            <div class="editor-label">
                @Html.LabelFor(model => model.TenSanPham)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.TenSanPham)
                @Html.ValidationMessageFor(model => model.TenSanPham)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.MoTa)
            </div>
            <div class="editor-field">
               @Html.TextAreaFor(model => model.MoTa, new { @id = "ckeMoTa" })
                <script type="text/javascript">
                    CKEDITOR.replace("ckeMoTa");
                </script>
                @Html.ValidationMessageFor(model => model.MoTa)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.HinhAnh)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.HinhAnh)
                @Html.ValidationMessageFor(model => model.HinhAnh)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Gia)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Gia)
                @Html.ValidationMessageFor(model => model.Gia)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.SoLuong)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.SoLuong)
                @Html.ValidationMessageFor(model => model.SoLuong)
            </div>

            @if(Model.LoaiSanPham.SubLoaiSanPham == ProjectThuCung.Models.SubLoaiSP.ThuCung)
            {
                @Html.HiddenFor(model => model.ThongTinThem.ThongTinThemID)
            
                <div class="editor-label">
                    @Html.LabelFor(model => model.ThongTinThem.GioiTinh)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ThongTinThem.GioiTinh)
                    @Html.ValidationMessageFor(model => model.ThongTinThem.GioiTinh)
                </div>
            
                <div class="editor-label">
                    @Html.LabelFor(model => model.ThongTinThem.Giong)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ThongTinThem.Giong)
                    @Html.ValidationMessageFor(model => model.ThongTinThem.Giong)
                </div>
            
                <div class="editor-label">
                    @Html.LabelFor(model => model.ThongTinThem.Mau)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ThongTinThem.Mau)
                    @Html.ValidationMessageFor(model => model.ThongTinThem.Mau)
                </div>
            
                <div class="editor-label">
                    @Html.LabelFor(model => model.ThongTinThem.ThangTuoi)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ThongTinThem.ThangTuoi)
                    @Html.ValidationMessageFor(model => model.ThongTinThem.ThangTuoi)
                </div>
            
                <div class="editor-label">
                    @Html.LabelFor(model => model.ThongTinThem.TrongLuong)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ThongTinThem.TrongLuong)
                    @Html.ValidationMessageFor(model => model.ThongTinThem.TrongLuong)
                </div>
            }

            <div class="editor-label">
                @Html.LabelFor(model => model.XuatXu.TenXuatXu)
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(model => model.XuatXuID, (IEnumerable<SelectListItem>)ViewData["ListXuatXu"])
            </div>

            <p>
                <input type="submit" value="Lưu lại" />
            </p>
        
        </fieldset>
    }

    <div>
        @Html.ActionLink("quay lại", "Details", new { id = Model.LoaiSanPhamID, message = "",  page = (int)ViewBag.directPage})
    </div>
</div>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
